#include "Input.h"

cInput::cInput(DWORD keyboardCoopFlags, DWORD mouseCoopFlags, HWND hWnd, HINSTANCE hInst) 
{
	//Creates the Direct Input Object
	HRESULT hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&m_pDInput, NULL);

	//Create the objects for the Input Interface
	m_pKeyboard		= new cKeyboard(keyboardCoopFlags, m_pDInput, hWnd);
	m_pMouse		= new cMouse(mouseCoopFlags, m_pDInput, hWnd);
	m_pController	= new cController(1);
}

cInput::~cInput() 
{
	delete m_pController;
	delete m_pKeyboard;
	delete m_pMouse;
}

void cInput::Poll() 
{
	if(m_pMouse != NULL)
	{
		m_pMouse->Poll();
	}

	if(m_pKeyboard != NULL)
	{
		m_pKeyboard->Poll();
	}
}

cKeyboard* cInput::makeKeyboard()
{
	//Returns the object of the keyboard device
	return m_pKeyboard;
}

cMouse* cInput::makeMouse()
{
	//Returns the object of the mouse device
	return m_pMouse;
}

cController* cInput::makeController()
{
	//Returns the object of the controller device
	return m_pController;
}